<?php
include("config.php");
$login = $_SESSION['login'];
$haslo = $_SESSION['haslo'];
if ((empty($login)) AND (empty($haslo))) {
echo '<br>Musisz się zalogować, aby dodać dane do bazy.<br>';
exit;
}
$user = mysql_fetch_array(mysql_query("SELECT * FROM logowanie WHERE `login`='$login' AND `haslo`='$haslo' LIMIT 1"));
    if (empty($user[id]) OR !isset($user[id])) {
echo '<br>Nieprawidłowe logowanie.<br>';
exit;
}


$tytul = $_POST['tytul'];
$answer1 = $_POST['answer1'];
$answer2 = $_POST['answer2'];
$answer3 = $_POST['answer3'];
$answer4 = $_POST['answer4'];
$answer5 = $_POST['answer5'];
$answer6 = $_POST['answer6'];

$query = mysql_query("INSERT INTO `wojtex_cba_pl`.`ankiety` (`id`, `tytul`, `answer1`, `answer2`, `answer3`, `answer4`, `answer5`, `answer6`) VALUES (NULL, '$tytul', '$answer1', '$answer2', '$answer3', '$answer4', '$answer5', '$answer6');");
 
if ($query) 
{
echo '<p>Dodano do bazy</p>';
} 
else 
{
echo mysql_error();
echo '<p>Błąd! Spróbuj ponownie</p>';
}




echo '<br><a href="?kategoria=wyloguj">Wyloguj mnie</a>';
?>
